<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    // map 的使用
    var join = { name: "john" };
    updata = new map();
    updata.set(john, 123);
    alert(updata.get(john)); // 123

    let john = { name: "John" };

    let visitsCountObj = {}; // 尝试使用对象

    visitsCountObj[john] = 123; // 尝试将 john 对象作为键

    // 是写成了这样!
    alert(visitsCountObj["[object Object]"]); // 123



    // 每一次 map.set 调用都会返回 map 本身，所以我们可以进行“链式”调用：

    // map.set('1', 'str1')
    //     .set(1, 'num1')
    //     .set(true, 'bool1');


    let set = new Set();

let john = { name: "John" };
let pete = { name: "Pete" };
let mary = { name: "Mary" };

// visits，一些访客来访好几次
set.add(john);
set.add(pete);
set.add(mary);
set.add(john);
set.add(mary);

// set 只保留不重复的值
alert( set.size ); // 3

for (let user of set) {
  alert(user.name); // John（然后 Pete 和 Mary）
}
let user = {
  name: "John",
  age: 30
};

 for(let value of  object.value(user){
alert (value)
 })

 let user = {
  name: "John",
  age: 30
};
Object.keys(user) = ["name", "age"]
Object.values(user) = ["John", 30]
Object.entries(user) = [ ["name","John"], ["age",30] ]

let user = {
  name: "John",
  age: 30
};

let doublePrices=object.fromEntries(
    object.entries(user).map(([key,value])=>[key,value*2])
)

let prices = {
  banana: 1,
  orange: 2,
  meat: 4,
};

let doublePrices = Object.fromEntries(
  // 转换为数组，之后使用 map 方法，然后通过 fromEntries 再转回到对象
  Object.entries(prices).map(([key, value]) => [key, value * 2])
);

alert(doublePrices.meat); // 8

let salaries = {
  "John": 100,
  "Pete": 300,
  "Mary": 250
};



function up(salaries){
let sum=0;
 for(let sa of object.values(salaries)){
     sum+=sa
 }
 return sum
}
alert( sumSalaries(sa) ); // 650



let salaries = {
  "John": 100,
  "Pete": 300,
  "Mary": 250
};
alert(count(salaries))

 function count(salaries){
    return Object.keys(salaries).length
 }
 console.log(count(salaries));
 

</script>